home *** CD-ROM | disk | FTP | other *** search
- ' This module contains sample code that must be placed in forms
- ' This is necessary because the routines reference controls on the form
- ' To use these routines:
- ' add this module to the project
- ' copy the desired routines to your form code
- ' remove this module from the project (this code will create errors if included)
- '
- ' The routines present are:
- ' FldGotFocus: highlights a field and displays help in cmsg control
- ' to use add following in GotFocus event FldGotFocus control-name
- ' FldLostFocus: removes highlight from a field and removes help in cmsg control
- ' to use add following in LostFocus event FldLostFocus control-name
- ' ShowHelp: displays popup help for a control (button, etc)
- ' to use add following in MouseMove event ShowHelp control-name, x, y
- ' in events that perform action, e.g. Click add ShowHelp control-name, 0, 0
- '
- ' See the routines for additional information
- '
- ' Provided courtesy of RDB Systems, Royce D. Bacon.
- ' Compuserve Id: 70042,1001
- ' You are free to use these routines in any way you desire
- ' Of course, I'm not responsible for the results
- '
-
- Sub FldGotFocus (PControl As Control)
- PControl.BackColor = BLUE
- PControl.ForeColor = WHITE
- PControl.SelStart = 0
- PControl.SelLength = 1000
- cmsg.Caption = PControl.Tag
-
- End Sub
-
- Sub FldLostFocus (PControl As Control)
- PControl.BackColor = RB_GRAY
- PControl.ForeColor = BLACK
- cmsg.Caption = ""
-
- End Sub
-
- Sub ShowHelp (PBtn As Control, px As Single, py As Single)
- ' Subroutine to show popup help for a control
- ' To use:
- ' add a panel control called PnlHelp to the form
- ' Set control's tag property to help message desired
- ' Copy this subroutine to the form code
- ' In mousemove event of control add
- ' ShowHelp control-name, x, y
- ' In click event or other events of control that cause action add
- ' ShowHelp control-name, 0, 0 ' Hides help
-
- Dim maxx As Single, maxy As Single
- Dim nPnlTop As Single, nPnlLeft As Single
- ' Determine max x & y coordinates with 80 twip border
- ' boundry of 80 twips allowed to be able to catch cursor as exiting control
- maxx = PBtn.Width - 80
- maxy = PBtn.Height - 80
- ' if exiting control area turn off help panel
- If px < 80 Or py < 80 Or px > maxx Or py > maxy Then
- PnlHelp.Visible = False
- PnlHelp.Caption = ""
- Exit Sub
- End If
-
- ' Determine location for help panel
- ' Assume below and to right
- nPnlTop = PBtn.Top + PBtn.Height + 40
- nPnlLeft = PBtn.Left + 100
- ' Put panel above control if not enough room below
- If nPnlTop + PnlHelp.Height > Height - 1024 Then
- nPnlTop = PBtn.Top - PnlHelp.Height - 40
- End If
- ' Put panel to left if not enough room to right
- If nPnlLeft + PnlHelp.Width > Width - 500 Then
- nPnlLeft = PBtn.Left + PBtn.Width - 40
- End If
-
- ' if same settings exit to prevent flickering effect
- If PnlHelp.Caption = PBtn.Tag And PnlHelp.Top = nPnlTop And PnlHelp.Left = nPnlLeft Then
- Exit Sub
- End If
-
- ' get help msg from control's tag and position help panel
- PnlHelp.Caption = PBtn.Tag
- PnlHelp.Top = nPnlTop
- PnlHelp.Left = nPnlLeft
- PnlHelp.Visible = True
-
- End Sub
-
-